<%@ page pageEncoding="utf-8" session="false" contentType="text/html; charset=utf-8"%>
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta http-equiv="Pragma" content="no-cache"/>
<meta http-equiv="Cache-Control" content="no-cache"/>
<meta http-equiv="Expires" content="0"/>
<link rel="stylesheet" type="text/css" href="${contextPath}/resource/note/css/tree.css"/>
<script type="text/javascript" src="${contextPath}/resource/htree/htree.js"></script>
<script type="text/javascript" src="${contextPath}/resource/htree/htree.util.js"></script>
<script type="text/javascript" src="${contextPath}/resource/user/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="${contextPath}/resource/user/user.js"></script>
<script type="text/javascript" src="${contextPath}/resource/note/note.js"></script>
<script type="text/javascript">
//<![CDATA[
window.getSelectedObject = function() {
    return HTree.getUserObject(HTree.getActive());
};

window.getSelectedId = function() {
    return getCategoryId(HTree.getActive());
};

window.getCategoryId = function(src) {
    var categoryId = null;
    var userObject = HTree.getUserObject(src);

    if(userObject != null) {
        categoryId = parseInt(userObject.categoryId);

        if(isNaN(categoryId)) {
            categoryId = null;
        }
    }
    return categoryId;
};

jQuery(function() {
    var id = "htree";
    var url = PageContext.getContextPath() + "/note/category/getBookXml.html";
    var type = PageContext.getAttribute("selectType");

    if(type == "category") {
        HTree.click = function(a) {
            HTree.setActive(HTree.getNode(a));
        };
    }
    else {
        HTree.click = function(a) {
            var node = HTree.getNode(a);
            var userObject = HTree.getUserObject(a);
    
            if(userObject.categoryId != "0") {
                HTree.setActive(node);
            }
        };
    }

    HTree.config.stylePath = PageContext.getContextPath() + "/resource/htree/note/";
    var tree = new HTree.TreeNode({text: "我的笔记", href: "?type=category&categoryId=0", xmlSrc: url});

    tree.load(function() {
        HTree.clicked = null;
        this.render(document.getElementById(id));
    });
});
//]]>
</script>
</head>
<div id="menu-body" class="resize-d" style="margin: 0px; padding: 0px; overflow: auto;">
    <div id="htree" class="htree" style="margin: 0px; padding: 0px; white-space: nowrap;"></div>
</div>
<div id="pageContext" class="hide" contextPath="${contextPath}" selectType="${type}"></div>
</body>
</html>
